package com.itheima.edu.info.manager.day5;

public class KuaiPai {
    public static void main(String[] args) {
        int[] arr = {3, 5, 7, 4, 1, 0, 6, 2, 8, 9};
        getC(arr, 0, arr.length - 1);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

    public static void getC(int[] arr, int c, int b) {
        if(b<c){
            return;
        }
        int c1 =c;
        int b1=b;
        int d=arr[c];
        while (c != b) {
            //c小于c1就进去c1就++，找的是比c小的数
            while (arr[b]>=d && b > c) {
                b--;
            }
            //c大于c1就进去b就++，找的是比c大的数
            while (arr[c] <= d && b > c) {
                c++;
            }
            int t = arr[c];
            arr[c] = arr[b];
            arr[b] = t;
        }
        int t=arr[c];
        arr[c]=arr[c1];
        arr[c1]=t ;

        getC(arr,c1,c-1);
        getC(arr,c+1,b1);
    }
}
